﻿CREATE TABLE [dbo].[User] (
    [UserId]           INT          IDENTITY (1, 1) NOT NULL,
    [UserName]         VARCHAR (50) NULL,
    [OpenId]		   VARCHAR (50) NULL,
    [CreateDate]       DATETIME     NULL,
    [CarId]            INT          NULL,
    [CarBatteryStatus] INT          NULL,
    [LocationId]       INT          NULL,
    [ChargingTimes]    INT          NULL,
    [LimitTimes]       INT          NULL,
    [GUID]             NCHAR (36)   NULL,
    [UpdateTime]       DATETIME     NULL,
	[nickname]		   VARCHAR(20)  NULL,
	[sex]			   CHAR(1)      NULL,
	[province]         VARCHAR(30)  NULL,
	[city]			   VARCHAR(30)  NULL,
	[country]          VARCHAR(50)  NULL,
	[headimgurl]       VARCHAR(600) NULL,
    CONSTRAINT [PK_User] PRIMARY KEY CLUSTERED ([UserId] ASC),
    CONSTRAINT [FK_User_Car] FOREIGN KEY ([CarId]) REFERENCES [dbo].[Car] ([CarId]),
    CONSTRAINT [FK_User_Location] FOREIGN KEY ([LocationId]) REFERENCES [dbo].[Location] ([LocationId])
);

